from pydantic import BaseModel, EmailStr, Field
from typing import List, Optional
from datetime import datetime


class UserCreate(BaseModel):
    email: str = Field(example="admin@qq.com")
    username: str = Field(example="admin")
    password: str = Field(example="123456")
    is_active: Optional[bool] = True
    is_superuser: Optional[bool] = False
    roles_id: Optional[int] = Field(1, description="角色ID")
    dept_id: Optional[int] = Field(1, description="部门ID")

class UserUpdate(BaseModel):
    id: int = 3
    email: str
    username: str
    password: str
    is_active: Optional[bool] = True
    is_superuser: Optional[bool] = False
    roles_id: Optional[int]
    dept_id: Optional[int]

# 登录用户
class CredentialsSchema(BaseModel):
    username: str = Field(..., description="用户名称", example="admin")
    password: str = Field(..., description="密码", example="123456")

# JSON Web Token
class JWTOut(BaseModel):
    access_token: str
    username: str
